Skip to content

[fold013 resolution for #2075 with #2071 + #2069, do not merge] #2082 + #2077 - #2083

Merged
jonathan308 merged 44 commits into
release/candidate-0.10.13from
fix/json-answer-grammar-bonsai-lightning-fold013-gemma
Nov 13, 2026
Merged

jonathan308 merged 44 commits into
release/candidate-0.10.13from
fix/json-answer-grammar-bonsai-lightning-fold013-gemma

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Do not merge. Fold vehicle for #2075 only if #2071 and #2069 ride before it (item 2075@b6c797c324); otherwise
use #2082 (2075@0c18951719). CI only.

Head b6c797c324 = merge 08b2a6a0c1 (#2082's 97ea9cfe36 (#2075 + candidate a2652e06f2) merged with #2077 59d434e7a3, #2071 + #2069) + #2082's docs fix 0c18951719.

File Kind Resolution
ToolConstraintFactory.swift textual #2071's Gemma JSON-answer block kept ahead of #2075's JSONAnswerPolicy block
GemmaJSONAnswerConstraint.swift semantic (compile) firstAddedTokenID: 0 → bpeIDs: 0..<0 (as items/2075.fix.py by GEMMA-JSON)
QwenStrictToolGrammar.swift (#2069) semantic (compile) firstAddedTokenID: 248044 → bpeIDs: 0..<248044 (same ids; not yet in items/2075.fix.py)
flowchart LR
  subgraph Before
    A[candidate + #2077] -->|merge #2082| X[conflict + 2 compile breaks]
  end
  subgraph After
    B[candidate + #2077] -->|merge 08b2a6a0c1| C[clean, compiles]
  end
Loading

jonathan308 and others added 30 commits November 13, 2026 00:04
The tests and the API, no behaviour: GemmaAnswerPieces decodes nothing,
GemmaJSONAnswerPolicy declines every request, and the constraint admits
nothing, so the new suites fail.

- GemmaAnswerPiecesTests: SentencePiece pieces as the bytes the decoder
  writes (U+2581 spaces, non-ASCII byte fallback, no ASCII byte fallback,
  control tokens and <unusedN> slots never text), and the pinned contract
  (marker ids, 262,144 ids, terminators among the engine stops).
- GemmaJSONAnswerConstraintTests: one JSON value across token boundaries;
  non-ASCII bytes only inside strings; fences, prose and endless blank lines
  refused; a free thought then the answer (the close as its token, spelled
  from pieces, or fused with the value); no control spelling in the answer;
  schemas (nested, enums, required, maxItems, keys once); root scalars; the
  mask independent of the budget; past the state cap the answer continues
  unconstrained.
- GemmaJSONAnswerPolicyTests: eligibility per model type, format and
  thinking; the DARKBLOOM_GEMMA_JSON_ANSWERS switch and its launchd
  passthrough; out-of-scope requests keep today's path; unsupported schemas
  (incl. $ref) fall back to a JSON object or prompt-only, never a refusal;
  a cluster pair or native-tracked engine gets no Gemma JSON constraint.
- GemmaJSONAnswerServingTests: through the scheduler and bridge, streaming,
  thought then answer through the Gemma 4 parser, a fence dropped, a
  budget cut stays length with no error, unformatted requests unchanged.
- GemmaJSONAnswerRealTokenizerTests (DARKBLOOM_TEST_GEMMA_TOKENIZER_DIR):
  every piece equals the shipped tokenizer's decode; real prompts and answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e thought

OpenRouter scores 2.1-5.0 % of Gemma 4's structured outputs as failures
(41K-108K a day): the provider neither constrained nor checked them.

A text request on gemma4 / gemma4_text with a JSON response_format, no
tools, no tool_choice, no client stop, the gemma4 reasoning parser and the
pinned chat template now samples under GemmaJSONAnswerConstraint:

- Vocabulary: Gemma's tokenizer is SentencePiece BPE with byte fallback, not
  byte-level. GemmaAnswerPieces gives every id the bytes its decoder writes
  (U+2581 a space, <0x80>..<0xFF> that byte, other pieces their UTF-8); the
  24 added tokens, <unusedN> slots and ASCII byte-fallback tokens are never
  text (a byte-fallback run that is not UTF-8 decodes to U+FFFD per token,
  so an ASCII byte spelled that way could vanish). Pinned: <|channel> 100,
  <channel|> 101, <turn|> 106, <eos> 1, exactly 262,144 ids, terminators
  among the engine stops. Built once per tokenizer and stop set.
- Phases: thinking off renders a closed empty thought, so output starts in
  the answer; thinking on may open a free thought (no EOS, no added token)
  that the first <channel|> ends, as its token or spelled from pieces, or
  answer at once. The answer is one JSON value of the shared FlintJSONGrammar
  (json_object, or json_schema within the subset); no Gemma control spelling
  completes in it; <turn|>/<eos> only once the value is complete, and after a
  self-delimited value the terminator only. Whitespace outside strings runs
  at most 64 bytes, so a model reaching for a fence cannot loop on newlines.
- Best effort: no post-validation, so a budget cut stays length as before;
  past 16,384 interned states the answer continues unconstrained instead of
  failing; an unsupported json_schema with an object root is held to a JSON
  object, any other keeps prompt-only steering; a cluster pair or
  native-tracked engine (which refuse token constraints) gets the request
  unconstrained (EngineV2Bridge.admittedConstraint).
- DARKBLOOM_GEMMA_JSON_ANSWERS=off restores prompt-only answers; LaunchAgent
  passes it to the launchd job.

A constrained row never drafts (mtpBasicEligible); on Gemma's non-recurrent
target its decode steps run target-only for every row in them, as a stop or
penalty row does today. Docs: inference.md, configuration.md; changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s in the sampler (red)

The API only (no request is constrained yet) and the tests: nested objects,
arrays, enums, integers vs strings, $ref/$defs, anyOf with null and open
objects, required/optional/duplicate/undeclared parameters, reasoning on and
off, multiple calls, auto vs required/named/none, unsupported keywords left
unconstrained, the per-model switch and its launchd passthrough, the parser
reading against Qwen35ToolCallParser, random calls drawn from the masks, and
streamed deltas through the router and through the scheduler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iew fixes

From the independent review of ab972c2 (APPROVE WITH NITS) and the first
local compile:

- Mask keys: states that differ only in a whitespace run no piece can push past
  the 64-byte cap admit the same tokens, so they share one mask key
  (GemmaJSONAnswerBoundary.maskEquivalent, using the vocabulary's longest
  leading whitespace run, 31 bytes for Gemma 4). Indentation no longer
  multiplies O(vocabulary) mask builds and uploads.
- Host memory: no per-state allowed-set cache (the sampler keeps the uploaded
  mask per key); at most two broad allowed sets per request.
- A tool-free tool_choice "auto" is eligible (the same request).
- "held to a JSON object" is logged only once the constraint is built.
- Comments and docs: a byte-fallback run decodes as a whole (U+FFFD for a run
  that is not UTF-8); no tokenizer clean-up for Gemma; leading whitespace before
  the thought stays content.
- Tests: compile fixes (raw strings holding "#, nested #require, a Sendable
  static fixture); a long pretty-printed answer stays far below the state cap
  and shares masks; whitespace runs share a key until the cap is in reach; an
  enum spelling a Gemma control in an object root is held to a JSON object;
  the real-tokenizer check tolerates swift-transformers' clean-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s in the sampler

A strict auto call is checked against the caller's schema when its frame
closes, after the answer started streaming, so a call that missed the schema
failed a started response (OpenRouter's main remaining Qwen 3.8 uptime cause).
On Qwen 3.8, 3.6 and 3.5 (qwen3_5, qwen3_5_moe) on one Mac the sampler now
holds every call of a request that declares a strict function to the declared
schemas: a declared function, declared parameters at most once, required ones
before </function>, and values the call parser reads as schema-valid
arguments (text, an enum's exact values, or one JSON value of the declared
schema, by the parameter's rendered type). Reasoning and text stay free, auto
still decides whether to call, and the prompt does not change.

Local $ref/$defs are inlined like the coordinator's resolver; anyOf/oneOf
with null, a single allOf and objects beside an open object are folded;
annotations (format included) are dropped. A schema outside the shared
subset, a cluster pair, a native-tracked engine, media, another family or
tool choice keep today's unconstrained calls, never a refusal. The loop guard
stays on for these requests. A constrained row drafts no MTP tokens (SDK).

DARKBLOOM_STRICT_TOOL_GRAMMAR (off word = today; a list picks builds) and
DARKBLOOM_STRICT_TOOL_GRAMMAR_ALL_TOOLS (also non-strict requests) reach
launchd providers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e suite's SplitMix64; a real-tokenizer walk

The property test's generator was a second internal SplitMix64 in the
ProviderCoreTests target (ThroughputSweepTests and SSDBlockIndexTests declare
one); it is a private StrictGrammarRandom now. A suite gated by
DARKBLOOM_TEST_QWEN_TOKENIZER_DIR builds the vocabulary from the shipped Qwen
tokenizer, checks the rendered prompt boundary with tools for thinking on and
off, and walks a real tokenization of a call through the grammar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… state-cap walk reaches a fourth state

The synthetic Gemma tokenizer spelled "model" and "thought" one character at
a time, so the rendered prompt's tail outgrew ReasoningPromptProbe's eight
tokens and the policy (correctly) declined: the shipped tokenizer keeps both
words whole (checked by GemmaJSONAnswerRealTokenizerTests). A string body is
one interned state, so the state-cap test now walks to the colon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Behavior-preserving, from the required refactor-pass subagent
(earnings/gemma-json-evidence/review/REFACTOR.md): one guard for the bounded
state in nextState and Node.maskEquivalent for the mask-key bookkeeping;
clearer private names (thoughtOpen, thoughtCloseMarkers,
extendWhitespaceRun); comments and the inference.md section corrected (the
answer ends with <turn|> or <eos>; the thought admits the two thought
markers; the caps named); test fixture shorthands. Token sets, transitions,
mask keys and interning are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cost as the engine applies it

A nested JSON string could end in a lone \uD800-\uDFFF escape, which the
parser's JSONSerialization refuses, leaving the whole object or array
parameter a string the strict check rejects (review M1). JSON values now
never spell a surrogate escape (nor a backslash before such text); other
escapes and characters written as such are unchanged. Each span's markers are
built once per constraint instead of per byte.

As with constrained JSON answers, a constrained row stops MTP speculation for
every row of the decode steps it shares on these engines, not only its own
(review M2): docs, changelog and the policy's comment say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re grammar-constrained (red)

Red first: JSONAnswerFamilyTests expects tool-free JSON response_format
answers on the Bonsai 2 builds (prism_hadamard_qwen35, Qwen 3.5's tokenizer)
and on Nemotron 3.5 Lightning (nemotron_h listing) to get a
JSONAnswerConstraint, and unlisted builds and DARKBLOOM_JSON_ANSWER_GRAMMAR=qwen
to keep prompt-only steering. The policy surface is in place (QwenJSONAnswerPolicy
becomes JSONAnswerPolicy with per-family profiles; JSONAnswerProfile carries its
BPE id range so Nemotron's added tokens at 0...999 are skipped; the
nemotron35 and bonsai2 contracts), but no new family is admitted yet, so the
admission tests fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vior change)

From the dedicated refactor-pass subagent (AGENTS.md): drop the unused
isInsideCall, build the JSON value markers from the text ones, correct a test
suite name and the switches' on words in comments, and keep the forbidden
spellings once as strings. Masks, transitions, eligibility, switches and the
hook API are unchanged; the suite passes (20/20 in the trimmed local run).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…N answers) for the 0.10.13 fold

Resolution branch for the fold (do not merge on its own). The only conflict is
the LaunchAgent doc comment both PRs added after the cold-load line: both kept,
#2069's first (its fold order). The passthrough list carries every switch:
DARKBLOOM_GEMMA_JSON_ANSWERS, DARKBLOOM_STRICT_TOOL_GRAMMAR and
DARKBLOOM_STRICT_TOOL_GRAMMAR_ALL_TOOLS. The constraint paths are disjoint: the
Gemma JSON policy answers inside ToolConstraintFactory.make for tool-free
gemma4 requests; the strict grammar's block runs after it only when no
constraint was built, for Qwen 3.5-family tool requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…llow their schema in the sampler

JSONAnswerPolicy admits two more families to the JSON-answer grammar the Qwen
3.5 family already uses (JSONAnswerConstraint), each on its own pinned token
contract:
- PrismML Bonsai 2 (prism_hadamard_qwen35, the listed 27B and 9B builds):
  Qwen 3.5's tokenizer (base vocabulary and added tokens identical to Qwen 3.8's),
  so the qwen35 ids under the family name Bonsai.
- Nemotron 3.5 Lightning (nemotron_h, the Lightning listing ids; Nano shares the
  type and is not admitted): special and added tokens at 0...999, byte-level BPE
  at 1000...131071, <think> 12 and </think> 13 as output pieces, <|im_end|> 11 and
  </s> 2 as answer terminators.

On the signed 0.10.12 (Mac B, 144 answers each) Lightning with thinking off missed
the schema 8 times in 72 (raw newlines inside strings, prose, extra keys, wrong
types); each is impossible under the grammar. Bonsai 27B was valid 144/144.
DARKBLOOM_JSON_ANSWER_GRAMMAR=qwen keeps the grammar to the Qwen types (read at
launch, forwarded to the LaunchAgent). Docs: inference.md (the section and the
MTP note: Lightning's constrained rows don't speculate either), test.md,
configuration.md; changelog fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tokenizer decode; stamps

From the delta review of db19ace (APPROVE WITH NITS):
- every mask equals exactly the tokens its state accepts (plus the
  terminators once complete) across whitespace runs, in the opening phase and
  three answer positions, including the runs where mask sharing stops;
- the real-tokenizer check is exact again (the provider's loader turns the
  tokenizer's clean-up off for Gemma) and asserts that a space before
  punctuation survives;
- the changelog says a tool-free "auto" is covered; inference.md and
  configuration.md restamped 2026-11-13.

No source change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9ed42df)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… object

A json_object answer's root is an object, so the walk to the array position
starts with {"a": [1, (the bare [1, prefix was refused at the root, as it
must be).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9ed42df)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mpts on a single Mac, Bonsai's own terminator (review round 1 + refactor pass)

Independent review (REQUEST CHANGES) and the refactor pass:
- Bonsai 2 27B's artifact declares <|im_end|> alone as EOS, so the slot's stop set
  is {248046} and the Qwen contract (both terminators) never matched: bonsai2 now
  pins <|im_end|> as its one terminator (a slot that also stops at 248044 never
  samples it). The vocabulary checks the stop set before decoding the pieces.
- A cluster pair refuses any token constraint before reserving; Bonsai and
  Lightning pairs keep today's prompt-only service (servesDistributedPair is passed
  from the text path through ToolConstraintFactory to JSONAnswerPolicy). Qwen's
  pair behavior is unchanged.
- Both new families constrain answer-first prompts only
  (JSONAnswerProfile.constrainsReasoning false): a constrained row never drafts and
  on these targets no row in its step does, Lightning's reasoning runs to
  thousands of tokens, and the thinking answers met the schema in our checks
  (Lightning 72/72). This also removes the nested-<think> disagreement with
  Bonsai's splitter, which only arises while reasoning.
- Lightning: </s> is no longer a content or reasoning marker (no piece; the HTML
  close tag stays writable).
- The switch also narrows on 0, off, false, no, none.
- Refactor pass: pieceIDs -> bpeIDs, comment fixes, matchesModelID in the Bonsai
  arm, the test helper's unused parameter, the policy test split, docs wording.
- Tests: Bonsai with stops {248046} and both; reasoning-first prompts and pairs;
  the switch values; the hybrid8 and rollback Lightning ids; </s> writable; the
  opt-in real-tokenizer suite derives the stop set as a slot does
  (ModelEOSPolicy.artifactEOSTokenIds + the tokenizer's EOS) and covers Bonsai
  (DARKBLOOM_TEST_BONSAI_TOKENIZER_DIR) and Lightning.
- Docs (inference.md, test.md, configuration.md) and the changelog state the
  answer-first scope, the pair exclusion, and that these answers lose MTP and the
  loop guard and fail the format check when cut, like Qwen's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l marker stays text

A call now commits at <function= (after optional whitespace following
<tool_call>), where the parser and the frame scanner commit to one; any other
first byte is text again, as without the grammar, and the text watcher sees
the bytes since the marker. { (the JSON dialect) and a non-ASCII byte right
after the marker are refused (review S1). With parallel_tool_calls false no
call opens after the first one closed (S3).

A parameter the streamed call would expose as text while the parser converts
it (a {"type":"null"} parameter) declines the request:
QwenStrictToolSchema.streamsAsText mirrors Qwen35ArgumentStreamer and a test
checks it against the streamer (M3). The scheduler hook reads the switch
first and counts the grammar's setup, the first request's vocabulary build
included, in the profile's tool_constraint duration (S8). Opening masks are
cached by the bytes matched, stop tokens are merged into sorted masks instead
of re-sorting, and opaque-span masks are keyed by whether stops are allowed.

Tests: the mention, single-call and streamer-mirror tests; the property test
draws calls for the $ref and union fixtures too and checks each one parsed
and streamed. Docs and changelog: the free phases' tokens (S4), calls inside
the thought (S2), the exit-thinking continuation (S5), and the MTP cost with
up to 8 decode rows (M2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…de its keys

The LaunchAgent doc lines move next to the prompt-cache knobs, in the order of
the passthrough keys, which also keeps them off the line #2071 inserts after.
Comment only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hemas as written

The GPU check's one invalid answer of 100 (base 0.10.12: 87/100 valid; this
branch: 99/100) was a Pydantic schema (, $ref, an optional field as
anyOf with null) held to a JSON object: a stray token became a key.

ResponseSchemaRewrite rewrites a json_schema in the shapes common clients
generate into the shared subset where the result admits exactly the same
instances: local $refs into the root's $defs/definitions inlined (no
recursion, no escaped or remote pointers, annotations only beside them), a
one-branch allOf unwrapped, an anyOf of one schema and {"type":"null"} made
nullable (null added to its finite values), the root's $schema/$id/$comment
dropped, at most 4,096 nodes. Anything else keeps today's fallback (a JSON
object when the root is one, else prompt-only). The policy tries the request's
schema, then the rewrite, then the fallback.

Tests: the client shapes compile exactly ($defs, definitions + $schema,
allOf, nullable enum); the GPU check's Pydantic person keeps its keys and
requirements; recursive, remote, constrained and wider references still fall
back. Local: 61 tests in 10 suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9ed42df)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reasoning-first decline, pair plumbing tested (review round 2)

Independent review round 2 (REQUEST CHANGES, 1 blocker):
- B1: the </s> test fed the tokenizer's encoding, which maps </s> to its stop id;
  it now walks single-byte ids and also checks that id 2 is refused mid-string.
  The Nemotron vocabulary test walks the answer phase only, as served.
- S2: JSONAnswerPolicy.constraint takes servesDistributedPair without a default;
  a test passes the flag through ToolConstraintFactory.make for Bonsai and
  Lightning; JSONAnswerFamilyServingTests streams an answer-first Bonsai and
  Lightning row through the scheduler's forwarding body with the routing flags
  production passes (_testMakeEventStream gains preserveInnerReasoningSpans and
  absorbStrayThinkClose), valid and missed (typed 422 under the family's name).
- S3: the Bonsai 2 9B is no longer admitted: it drafts, and its JSON prompts
  render thinking off by default, so each JSON row would stop its whole decode
  cohort from speculating. Only the 27B (no drafter) joins.
- S4: the opt-in real-tokenizer checks are two suites with suite-level traits
  (BonsaiJSONAnswerRealTokenizerTests, NemotronJSONAnswerRealTokenizerTests).
- N2: a Bonsai or Lightning prompt that opens a thought is declined silently and
  before the schema compiles (Lightning's default path); Qwen's decline order
  and log lines are unchanged.
- N3: the slot's pair flag is read only for JSON response_format requests.
- N1: changelog and direct-mode.md state the constrained families' own 422 and
  drop the loop-guard phrase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, within its node budget

A JSON pointer reads "a/b" as a path and "a~1b" as the name "a/b", and a
fragment may percent-encode, so a definition whose name needs escaping is
never resolved: its references fall back instead of reaching the wrong
definition. Tests: escaped and nested pointers are refused, a definition graph
that doubles past 4,096 nodes is refused, zod's named shape (a root $ref) is
enforced as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…3 fold resolution

#2069 moved its LaunchAgent note above the template-loops line, so #2071 and
#2069 now also merge cleanly on their own; this tree equals that clean merge
(ecfa075 + a2ab578). The conflict here is only against this branch's
earlier resolution of the same comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a2ab578)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…06 to 2020-12

From the second delta review (REQUEST CHANGES at 0829cad):
- bounded work: the walk stops past the compiler's 16 levels and past 8
  references or compositions in a row, and tracks the references it is
  inlining in one set (insert and remove) instead of copying it per hop, so a
  4,000-hop chain or a 100-level chain is refused at once;
- a root $schema is dropped only when it names draft-06, draft-07, 2019-09 or
  2020-12 (draft-04 has no const, draft-03 spells required as a boolean); any
  other value keeps the fallback;
- $comment is dropped everywhere, not only at the root.

Tests: the rewrite's output for anyOf-null over an object, an array, const, a
type array and an enum with null, and for reference/allOf annotations and the
meta-schemas; refusals for draft-04, a non-string $schema, a two-branch allOf,
anyOf with a constraint beside it or a ["null"] branch, a non-object $defs,
escaped and self references, and the three bounds; nested $id, $anchor and
$defs fall back to a JSON object; the mask oracle also covers a position inside
a string and the closed value. Docs list the conditions. Local: 63 tests in 10
suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a2ab578)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hange)

The required refactor pass on ResponseSchemaRewrite (subagent report
review/REFACTOR-2.md): answerFormat compiles through one local helper behind
one json_schema guard and says the object fallback reads the request's own
root; the anyOf branch names the non-null branch once; the type doc and
inference.md say the unwrap bound counts compositions too and list the node
budget; the nullable-enum test schema is named instead of indexed. Local: 63
tests in 10 suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the third delta review (REQUEST CHANGES at e6bfd86): the budget
counted visits, but a visit may copy a node of any size, so a small body
(a 100,000-key definition reached from 2,000 properties) could copy
gigabytes. Each visit now costs one plus its node's keys, paid before any
change copies the node, and making an enum nullable costs its values;
maximumWork (16,384) replaces maximumNodes. A root $schema needs its
http(s) scheme. The type doc says properties and items are rewritten
whatever the node's type.

Tests: a 64-property fan-out to a 5,000-key definition is refused; the depth
bound is pinned (16 levels rewritten and taken by the compiler, 17 refused);
a scheme-less $schema is refused. Local: 63 tests in 10 suites pass.

A mistyped annotation (a non-string $comment or root $id) is still dropped,
as the compiler reads annotations without type checks; instances are
unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 and others added 12 commits November 13, 2026 01:59
a2ab578)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the fourth delta review (REQUEST CHANGES at 2354404, the rest APPROVE
WITH NITS): string hashing is linear in length and was not charged, so a
long reference or property name reached from many places could burn CPU on
the request path. A reference costs one unit per 64 bytes of its path before
it is looked up, inserted or removed, a property name the same before it is
hashed, and the annotation check refuses a key longer than 11 bytes (no
keyword or annotation is longer) before hashing it.

Tests: a 100,000-byte reference reached from 64 properties and 64 property
names of 32,768 bytes are refused. Local: 63 tests in 10 suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a2ab578)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, degenerate answers, pairs (review round 3)

Review round 3 (APPROVE WITH SHOULD-FIX):
- inference.md and the changelog: only Lightning's thinking-off JSON requests
  trigger the no-MTP path, and every Lightning row sharing their decode step
  stops speculating meanwhile (was: thinking requests keep speculating).
- The grammar keeps an answer inside the schema, not on topic: one Lightning
  answer ran 1,955 tokens repeating its reply when the prompt asked for keys
  the schema forbids, and a json_object prompt that wasn't JSON-shaped put its
  prose in a key; these rows have no loop guard. The changelog no longer says
  "no prose", and cites darkbloom-platform #897 for the length finish.
- direct-mode.md and two-mac-cluster.md: Bonsai and Lightning are constrained
  on one Mac only; their pairs keep the format instruction.
- The Nemotron vocabulary walk asserts each token is allowed before taking it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the fifth delta review (APPROVE WITH NITS at 347dc46, finding 1
recommended before ready): a native non-ASCII key is compared by
normalizing, so a long run of combining marks made each dictionary probe
that landed on it linear in its length, unpaid. A visited node with a key
longer than additionalProperties (20 bytes, the compiler's longest) is
refused before any lookup, as the compiler would refuse it; a definition
name over 256 bytes is not registered; isNull checks the keys and the type's
length before comparing. No result changes for a schema the compiler takes.

Tests: a 21-byte key and a 257-byte definition name are refused, a 256-byte
name resolves. Local: 63 tests in 10 suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a2ab578)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…copy

From the sixth delta review (REQUEST CHANGES at 941157b): the compiler
reads a node's type and required names on every inlined copy, and their
length was the client's, so a fan-out of one definition could make the
compiler lowercase or hash megabytes per copy. The walk now bounds each as
the compiler could ever take it, before copies multiply: a type name of at
most 7 bytes (boolean, integer), a type array paid per member, at most 128
required names of at most 64 bytes each (a declared property name). Anything
else could never compile, so results are unchanged where the compiler
compiles; the type doc lists these refusals and the earlier key and
definition-name limits.

Tests: an 8-byte type name, an 8-byte type member, a 20,001-member type
array, a 65-byte and a 129th required name are refused; an upper-case
7-byte type, a [T, null, null] type and a short required list pass
unchanged. Local: 63 tests in 10 suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a2ab578)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c comments only)

The required refactor pass over the review-round hardening (2354404 to
3502545; subagent report review/REFACTOR-3.md): the type doc says the
key, type and required limits are what the compiler refuses wherever it
reads them, refused at every node (the seventh delta review's nit: the old
wording said "never"), and maximumWork's doc lists the per-member charges.
No executable line changed. One accepted boundary test from the same review:
a 64-byte property name, required. Local: 63 tests in 10 suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a2ab578)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…3 resolution)

#2075 (e7ded92) merged with the candidate's final fold, so the release can
fold it without a conflict. Each conflict is both sides adding beside each other:

- JSONAnswerProfile.swift: both sides' profiles are kept (Bonsai 2 and
  Nemotron 3.5 from #2075; GPT-OSS from #2045). #2075 replaced
  `firstAddedTokenID` with the `bpeIDs` range, so GPT-OSS's
  `firstAddedTokenID: 199998` is written `bpeIDs: 0..<199998` (the same ids).
- GPTOSSForcedToolConstraint.swift: `profile.firstAddedTokenID` reads
  `profile.bpeIDs.upperBound` (the same value, 199998).
- ToolConstraintFactory.swift: the header comment names both families.
- MultiModelBatchSchedulerEngine.swift: `_testMakeEventStream` forwards both
  sides' new parameters, in `makeEventStream`'s order.

No other line changes; libs/mlx-swift-lm stays at the candidate's 859f641529.
…old resolution

For a fold in which #2071 (Gemma 4 JSON answers) and #2069 (Qwen strict tool
calls) ride before #2075: 97ea9cf (#2075 + the candidate a2652e0)
merged with #2077.

- ToolConstraintFactory.swift (textual): #2071's Gemma JSON-answer block is
  kept ahead of #2075's `JSONAnswerPolicy` block; the comment names the policy.
- GemmaJSONAnswerConstraint.swift and QwenStrictToolGrammar.swift (semantic):
  #2075 replaced `JSONAnswerProfile`'s `firstAddedTokenID` with the `bpeIDs`
  range, so Gemma's `firstAddedTokenID: 0` is `bpeIDs: 0..<0` (no byte-level
  ids, as items/2075.fix.py does) and the Qwen tools profile's
  `firstAddedTokenID: 248044` is `bpeIDs: 0..<248044` (the same ids).
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference-landing Ready Ready Preview Nov 13, 2026 11:21am UTC
darkbloom-status Ready Ready Preview Nov 13, 2026 11:21am UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 13, 2026 11:21am UTC

Request Review

… a length finish on the fold (review)

On the 0.10.13 candidate, #2053 ends an answer cut at max_tokens as a normal
length finish with its content as generated, constrained JSON answers included
(MultiModelBatchSchedulerEngine skips JSONAnswerOutput.validate when
prepared.cutAtLimit). #2075's changelog fragment and docs still called it the
typed 422: they now say a miss at a natural stop is the 422 and a cut is a
length finish. The skipped-check notes name the JSON-answer families, not Qwen
alone. Comments and docs only (REVIEW-FOLD F1, N2).

This branch was successfully deployed

3 active deployments
Preview – eigen-homepages-darkbloom — b6c797c3 Deployed Nov 13, 2026 by vercel[bot]
Preview – d-inference-landing — b6c797c3 Deployed Nov 13, 2026 by vercel[bot]
Preview – darkbloom-status — b6c797c3 Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant